package com.lingyu.jsjx.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.lingyu.jsjx.domain.TeacherPeerEvaluation;
import com.lingyu.jsjx.service.ITeacherPeerEvaluationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 同行评价Controller
 * 
 * @author ruoyi
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/teacherPeerEvaluation")
public class TeacherPeerEvaluationController extends BaseController
{
    @Autowired
    private ITeacherPeerEvaluationService teacherPeerEvaluationService;

    /**
     * 查询同行评价列表
     */
    @RequiresPermissions("jsjx:teacherPeerEvaluation:list")
    @GetMapping("/list")
    public TableDataInfo list(TeacherPeerEvaluation teacherPeerEvaluation)
    {
        startPage();
        List<TeacherPeerEvaluation> list = teacherPeerEvaluationService.selectTeacherPeerEvaluationList(teacherPeerEvaluation);
        return getDataTable(list);
    }

    /**
     * 导出同行评价列表
     */
    @RequiresPermissions("jsjx:teacherPeerEvaluation:export")
    @Log(title = "同行评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeacherPeerEvaluation teacherPeerEvaluation)
    {
        List<TeacherPeerEvaluation> list = teacherPeerEvaluationService.selectTeacherPeerEvaluationList(teacherPeerEvaluation);
        ExcelUtil<TeacherPeerEvaluation> util = new ExcelUtil<TeacherPeerEvaluation>(TeacherPeerEvaluation.class);
        util.exportExcel(response, list, "同行评价数据");
    }

    /**
     * 获取同行评价详细信息
     */
    @RequiresPermissions("jsjx:teacherPeerEvaluation:query")
    @GetMapping(value = "/{peerEvalId}")
    public AjaxResult getInfo(@PathVariable("peerEvalId") Long peerEvalId)
    {
        return success(teacherPeerEvaluationService.selectTeacherPeerEvaluationByPeerEvalId(peerEvalId));
    }

    /**
     * 新增同行评价
     */
    @RequiresPermissions("jsjx:teacherPeerEvaluation:add")
    @Log(title = "同行评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeacherPeerEvaluation teacherPeerEvaluation)
    {
        return toAjax(teacherPeerEvaluationService.insertTeacherPeerEvaluation(teacherPeerEvaluation));
    }

    /**
     * 修改同行评价
     */
    @RequiresPermissions("jsjx:teacherPeerEvaluation:edit")
    @Log(title = "同行评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeacherPeerEvaluation teacherPeerEvaluation)
    {
        return toAjax(teacherPeerEvaluationService.updateTeacherPeerEvaluation(teacherPeerEvaluation));
    }

    /**
     * 删除同行评价
     */
    @RequiresPermissions("jsjx:teacherPeerEvaluation:remove")
    @Log(title = "同行评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{peerEvalIds}")
    public AjaxResult remove(@PathVariable Long[] peerEvalIds)
    {
        return toAjax(teacherPeerEvaluationService.deleteTeacherPeerEvaluationByPeerEvalIds(peerEvalIds));
    }
}
